﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.API.Application.Command.HealthInformation;
using Traceability.App.Domain.Traceability;
using Traceability.App.ErrorCode;

namespace Traceability.App.API.Controllers
{
    /// <summary>
    /// 保健信息控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HealthController : ControllerBase
    {
        private readonly IMediator mediator;

        public HealthController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取保健信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<HealthInformationModel>>> GetHealth([FromQuery]GetHealthCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 新增保健信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> CreateHealth(CreateHealthCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除保健信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<int>> DelHealth([FromQuery]DelHealthCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改保健信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> UpdHealth(UpdHealthCommand request)
        {
            return mediator.Send(request);
        }
    }
}
